<?php
$adminList = "";
$obj = "\$object_$class";
$Uclass = strtoupper($class);
$adminList .="<?php".$CR."include(\"../../config/config.php\");".$CR;
$adminList .="\$DM->loadClass(\"$package\",\"$class\");".$CR;
$adminList .="// create and instance class".$CR;
$adminList .=$obj." = new $class();".$CR;
$adminList .=$obj."->getList();".$CR;

$adminList .="?>".$CR;
$colspan = count($var)+1;
$adminList .= <<<html
<html>
<head>
	<title>$class</title>
	<link href="<?php echo HTTP_BASE?>/resource/includes/css/admin.css" type="text/css" rel="stylesheet" rev="stylesheet" />
	<script src="<?php echo HTTP_BASE?>/resource/includes/javascript/jquery/jquery-1.2.3.js"></script>
	<script>
	$(function(){
		$("#updateTD").css('cursor','pointer');
		$("#createTD").css('cursor','pointer');
		$("#showUpdate").css('cursor','pointer');
		$("#showCreate").css('cursor','pointer');

		$("#updateTD").click(function(){
			$(".updateTd").hide();
			$("#showUpdate").show();
		});
		$("#createTD").click(function(){
			$(".createTd").hide();
			$("#showCreate").show();
		});
		$("#showUpdate").click(function(){
			$(".updateTd").show();
			$("#showUpdate").hide();

		});
		$("#showCreate").click(function(){
			$(".createTd").show();
			$("#showCreate").hide();
		});
	});
	function apagar(_id){
		if (confirm('Erase this item from the system?')){
			window.location.href='$class.delete.php?id='+_id+'&apagar=apag';
		}
	}

	</script>
</head>
<body bgcolor="#FFFFFF" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<div id='header'>
	<h1>LISTA DE $Uclass</h1>
</div>
<div id='actionHeader'>
	<div align="right"><a href=$class.edit.php class='mainAction'>ADICIONAR $Uclass</a></div>
</div>
<table border="0" cellpadding="4" cellspacing="1" bgcolor="#efefef" width='100%'>
	<tr>
html;

for ($i=0;$i<count($var);$i++){
	$adminList .="		<td class='titleTd' align='center'>".$var[$i]["title"]."</td>".$CR;
}

$adminList .="		<td class='titleTd' align='center'>Actions</td>".$CR;
$adminList .="	</tr>".$CR;
$adminList .="<?php".$CR;

$adminList .="for (\$i=0;\$i<count(".$obj."->lista);\$i++){".$CR;
$adminList .="\t\$line = \$line!=\"line1\"?\"line1\":\"line2\";".$CR;

$adminList .="	".$obj."->".$var[0]["name"]."=".$obj."->lista[\$i][\"".$var[0]["name"]."\"];".$CR;
$adminList .="	".$obj."->getById();".$CR;
$adminList .="	echo \"<TR>".$CR;

for ($i=0;$i<count($var);$i++){
	if ($var[$i]["type"]=="ONOFF"){
		$ternary="==1?'ON':'OFF'";
	}else{
		$ternary='';
	}
	$adminList .="\t\t<td align='center' class='\$line'>\".(".$obj."->".$var[$i]["name"].$ternary.").\"</td>".$CR;

}
$adminList .="		<td align='center' class='\$line'><a class='minorAction' href='$class.edit.php?id=".$obj."->".$var[0]["name"]."'>editar</a> - <a class='minorAction' href='javascript:apagar(".$obj."->".$var[0]["name"].");'>apagar</a></td>".$CR;
$adminList .="	\";".$CR;
$adminList .="	echo \"</TR>\";".$CR;
$adminList .="}".$CR;
$adminList .="?>".$CR;
$adminList .="</table>
<div id=\"hiddenCols\">
	<div id=\"showUpdate\" class=\"titleTd\" style=\"float:left;margin:3px;width:200px;text-align:center;display:none;\">Reveal Update Column</div>
	<div id=\"showCreate\" class=\"titleTd\" style=\"float:left;margin:3px;width:200px;text-align:center;display:none;\">Reveal Create Column</div>
</div>
<div id='actionHeader'>
	<div align=\"right\"><a href='$class.edit.php' class='mainAction'>ADICIONAR $Uclass</a></div>
</div>
";

$adminList .= "</body></html>";
?>

